package com.unicom.projt.util;

/**
 * Created by IntelliJ IDEA.
 * User: Lee
 * Date: 11-12-5
 * Time: 上午11:08
 */
public class XmlBuilder {

    private static XmlBuilder xmlBuilder = new XmlBuilder();

    public static XmlBuilder getInstance() {
        return xmlBuilder;
    }

    private XmlBuilder() {
    }

    private String merchantId = "";
    private String merchantOrderId = "";
    private String merchantOrderTime = "";
    private String sign = "";
    private String pluginVersion = "";
    private String merchantName = "";
    private String merchantOrderAmt = "";
    private String transTimeout = "";

    public XmlBuilder setMerchantId(String merchantId) {
        this.merchantId = merchantId;
        return this;
    }

    public XmlBuilder setMerchantOrderId(String merchantOrderId) {
        this.merchantOrderId = merchantOrderId;
        return this;
    }

    public XmlBuilder setMerchantOrderTime(String merchantOrderTime) {
        this.merchantOrderTime = merchantOrderTime;
        return this;
    }

    public XmlBuilder setSign(String sign) {
        this.sign = sign;
        return this;
    }

    public XmlBuilder setPluginVersion(String pluginVersion) {
        this.pluginVersion = pluginVersion;
        return this;
    }

    public XmlBuilder setMerchantName(String merchantName) {
        this.merchantName = merchantName;
        return this;
    }

    public XmlBuilder setMerchantOrderAmt(String merchantOrderAmt) {
        this.merchantOrderAmt = merchantOrderAmt;
        return this;
    }

    public XmlBuilder setTransTimeout(String transTimeout) {
        this.transTimeout = transTimeout;
        return this;
    }

    public String buildXml() {
        StringBuilder sb = new StringBuilder();
        sb.append("<?xml version=\"1\" encoding=\"UTF-8\" ?><upomp application=\"UpPay.Req\"><merchantId>");
        sb.append(merchantId);
        sb.append("</merchantId><merchantOrderId>");
        sb.append(merchantOrderId);
        sb.append("</merchantOrderId><merchantOrderTime>");
        sb.append(merchantOrderTime);
        sb.append("</merchantOrderTime>");
        sb.append("<sign>");
        sb.append(sign);
        sb.append("</sign>");
        sb.append("<pluginVersion>");
        sb.append(pluginVersion);
        sb.append("</pluginVersion>");
        sb.append("<merchantName>");
        sb.append(merchantName);
        sb.append("</merchantName><merchantOrderAmt>");
        sb.append(merchantOrderAmt);
        sb.append("</merchantOrderAmt><merchantOrderDesc></merchantOrderDesc><transTimeout></transTimeout></upomp>");
        return sb.toString();
    }

    public String buildDefaultXml() {
        StringBuilder sb = new StringBuilder();
        sb.append("<?xml version=\"1\" encoding=\"UTF-8\" ?><upomp application=\"UpPay.Req\"><merchantId>");
        sb.append("303310048990001");
        sb.append("</merchantId><merchantOrderId>");
        sb.append("20111212135808005637");
        sb.append("</merchantOrderId><merchantOrderTime>");
        sb.append(merchantOrderTime);
        sb.append("</merchantOrderTime>");
        sb.append("<sign>");
        sb.append("Pfupg48IbKMuggGm302gfIVj7mhaiDr/lvvtLVv3moxAd5B6wrRqjWiPj+AuQCSNHBy359sgxSLzzj83IUZNcXGDp1OByPcHxHCrp50JPR26EUkvxjxmOmYIVMOy4bmjGxfWLz7bi0amxKkVV9OZQyycTYlYxUwRVf6X6e0B");
        sb.append("</sign>");
        sb.append("<merchantPublicCert>");
        sb.append("MIID3jCCA0egAwIBAgIQZpz4p9w399ivw7l7zFdr6zANBgkqhkiG9w0BAQUFADAqMQswCQYDVQQG" +
                "EwJDTjEbMBkGA1UEChMSQ0ZDQSBPcGVyYXRpb24gQ0EyMB4XDTExMDgyMzA4MjkxOFoXDTEzMDgy\n" +
                        "MzA4MjkxOFowgZAxCzAJBgNVBAYTAkNOMRswGQYDVQQKExJDRkNBIE9wZXJhdGlvbiBDQTIxETAP\n" +
                        "BgNVBAsTCExvY2FsIFJBMRQwEgYDVQQLEwtFbnRlcnByaXNlczE7MDkGA1UEAxQyMDQxQDgzMTAw\n" +
                        "MDAwMDAwODMwNDBAMzAzMzEwMDQ4OTkwMDAxOlNJR05AMDAwMDAxMTAwgZ8wDQYJKoZIhvcNAQEB\n" +
                        "BQADgY0AMIGJAoGBAKAAnRDlrJiwi34pb3neOugwuDcruadpkvW84fJY1rS3U1DM69JoAM+v1Uwc\n" +
                        "MIXSBvtGhUNjZHswFP3PYXtB5I61fV2zOi7UZ09FS38JVaTt65Ju/uxGqu+oYleiRuR/ehn89mCh\n" +
                        "xo8WUMi39NOvkxPdjLKWCMcEpffpR6RFTOqzAgMBAAGjggGcMIIBmDAfBgNVHSMEGDAWgBTwje2z\n" +
                        "Qbv77wgeVQLDMTfvPBROzTAdBgNVHQ4EFgQUoLjNF2ueQ5Uu5o3oROnrA7L7iy0wCwYDVR0PBAQD\n" +
                        "AgTwMAwGA1UdEwQFMAMBAQAwOwYDVR0lBDQwMgYIKwYBBQUHAwEGCCsGAQUFBwMCBggrBgEFBQcD\n" +
                        "AwYIKwYBBQUHAwQGCCsGAQUFBwMIMIH9BgNVHR8EgfUwgfIwVqBUoFKkUDBOMQswCQYDVQQGEwJD\n" +
                        "TjEbMBkGA1UEChMSQ0ZDQSBPcGVyYXRpb24gQ0EyMQwwCgYDVQQLEwNDUkwxFDASBgNVBAMTC2Ny\n" +
                        "bDEwNF8zODMzMIGXoIGUoIGRhoGObGRhcDovL2NlcnQ4NjMuY2ZjYS5jb20uY246Mzg5L0NOPWNy\n" +
                        "bDEwNF8zODMzLE9VPUNSTCxPPUNGQ0EgT3BlcmF0aW9uIENBMixDPUNOP2NlcnRpZmljYXRlUmV2\n" +
                        "b2NhdGlvbkxpc3Q/YmFzZT9vYmplY3RjbGFzcz1jUkxEaXN0cmlidXRpb25Qb2ludDANBgkqhkiG\n" +
                        "9w0BAQUFAAOBgQA5TiHWd+8KQkK4Msg+wbuZ8S3DTynpMLYaACnzC/w0KcgBkWhf+pfHXdnTYNCI\n" +
                        "Ek8cpcIi0Uao8S4wBRtvjwkP3dWc4U2L0Njf792nSyMx8xjTdy7FACCUk5w6X24ewRW9cFGOq44u\n" +
                        "qrGZGMmabrUpoAinmuqH7SqvEHmRtRdzeA==");
        sb.append("</merchantPublicCert>");
        sb.append("<pluginVersion>");
        sb.append("1.0.0");
        sb.append("</pluginVersion>");
        sb.append("<merchantName>");
        sb.append("翰鑫科技");
        sb.append("</merchantName><merchantOrderAmt>");
        sb.append(merchantOrderAmt);
        sb.append("</merchantOrderAmt>");
        sb.append("<respCode>");
        sb.append("0000");
        sb.append("</respCode>");
        sb.append("<respDesc>");
        sb.append("respDesc");
        sb.append("</respDesc>");
        sb.append("<merchantOrderDesc></merchantOrderDesc><transTimeout></transTimeout></upomp>");
        return sb.toString();
    }
}
